/*******************************************************************************
* This file provides the API for the I2C module.
*
* Author: Kong Wai Weng
* Email:  waiweng83@gmail.com
*******************************************************************************/



#ifndef _HAL_I2C_H
#define _HAL_I2C_H



#include <i2c.h>
#include "FreeRTOS.h"
#include "semphr.h"
#include "variables.h"
#include "system.h"



/*******************************************************************************
* PUBLIC FUNCTION PROTOTYPES                                                   *
*******************************************************************************/

/*******************************************************************************
* PUBLIC FUNCTION: vInitI2c1
*
* PARAMETERS:
* ~ void
*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* Initialize the I2C 1 module.
*
*******************************************************************************/
void vInitI2c1(void);



/*******************************************************************************
* PUBLIC FUNCTION: uiReadI2c1
*
* PARAMETERS:
* ~ uiI2cAddress	- The I2C slave address.
* ~ uiRegAddress	- The register address to read.
* ~ uiBytesCount	- Number of bytes to read.
* ~ pucBuffer		- Buffer for the received data.
*
* RETURN:
* ~ Return 1 if error occured.
* ~ Return 0 if no error.
*
* DESCRIPTIONS:
* Read from I2C 1.
*
*******************************************************************************/
unsigned int uiReadI2c1(	unsigned int uiI2cAddress,
							unsigned int uiRegAddress,
							unsigned int uiBytesCount,
							unsigned char* pucBuffer	);



/*******************************************************************************
* PUBLIC FUNCTION: uiWriteI2c1
*
* PARAMETERS:
* ~ uiI2cAddress	- The I2C slave address.
* ~ uiRegAddress	- The register address to read.
* ~ uiBytesCount	- Number of bytes to read.
* ~ pucBuffer		- Buffer for the received data.
*
* RETURN:
* ~ Return 1 if error occured.
* ~ Return 0 if no error.
*
* DESCRIPTIONS:
* Write to I2C 1.
*
*******************************************************************************/
unsigned int uiWriteI2c1(	unsigned int uiI2cAddress,
							unsigned int uiRegAddress,
							unsigned int uiBytesCount,
							unsigned char* pucBuffer	);



#endif
